package com.aaa.web.controller.marketcontroller;

import com.aaa.entity.AppExpensetype;
import com.aaa.entity.repair.BackEntrepot;
import com.aaa.entity.BackExpenseorder;
import com.aaa.entity.BackGoodstype;
import com.aaa.web.commons.EmpQuery;
import com.aaa.web.commons.Result;
import com.aaa.web.service.imarketservice.IMarketManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

/**
 * @ClassName MarketManageController
 * @Description 销售管理
 * @Author caolinlin
 * @Date 2018/12/18 15:35
 **/
@Controller
@RequestMapping("/market")
public class MarketManageController {

    @Autowired
    private IMarketManageService marketManageService;

    /**
     * 跳转到页面
     * @return
     */
    @RequestMapping("/getMarketPage")
    public String getMarketPage(){
        return "views/webhtml/market/marketManage";
    }

    /**
     * 获取全部订单数据
     * @param query
     * @param e
     * @return
     */
    @RequestMapping("/getMarketManage")
    @ResponseBody
    public Map getMarketManage(EmpQuery query, BackExpenseorder e){
        Map m= marketManageService.getMarketManage(query,e);
        return m;
    }

    /**
     * 获取该订单的详细信息
     * @param e
     * @return
     */
    @RequestMapping("/getDetailMarketManage")
    @ResponseBody
    public Map getDetailMarketManage(BackExpenseorder e){
        return marketManageService.getDetailMarketManage(e);
    }

    /**
     * 删除订单
     * @param e
     * @return
     */
    @RequestMapping("/delMarketByOrderId")
    @ResponseBody
    public Result delMarketByOrderId(BackExpenseorder e){
        return marketManageService.delMarketByOrderId(e);

    }

    /**
     * 生成订单号
     * @return
     */
    @RequestMapping("/getNewOrderNumber")
    @ResponseBody
    public Result getNewOrderNumber(){
        return marketManageService.getNewOrderNumber();

    }  /**
     * 获取消费类型列表
     * @return
     */
    @RequestMapping("/getExpenseTypeList")
    @ResponseBody
    public List<AppExpensetype> getExpenseTypeList(){
        return marketManageService.getExpenseTypeList();

    }
 /**
     * 获取商品类型列表
     * @return
     */
    @RequestMapping("/getGoodStypeAddList")
    @ResponseBody
    public List<BackGoodstype> getGoodStypeAddList(){
        return marketManageService.getGoodStypeAddList();

    }

    /**
     * 批量添加订单
     * @return
     */
    @RequestMapping("/addMarketManage")
    @ResponseBody
    public Result addMarketManage(@RequestBody  List<List<Map<String,Object>>> mapList){

        return marketManageService.addMarketManage(mapList);

    }

    /**
     * 根据 商品种类id 在 仓库表 中查询出 本地的 对应 商品种类 的商品
     * @param goodstypeId
     * @return
     */
    @RequestMapping("/selGoodsListById")
    @ResponseBody
    public List<BackEntrepot> selGoodsListById(int goodstypeId){
        List<BackEntrepot> list=marketManageService.selGoodsListById(goodstypeId);
        return list;
    }

    /**
     * 获取车辆列表
     * @return
     */
    @RequestMapping("/getCarsList")
    @ResponseBody
    public List<BackEntrepot> getCarsList(){
        List<BackEntrepot> list=marketManageService.getCarsList();
        return list;
    }

    /**
     * 获取仓库商品信息
     * @return
     */
    @RequestMapping("/getEntrepotGoods")
    @ResponseBody
    public Map getEntrepotGoods(int goodstypeId){
        return marketManageService.getEntrepotGoods(goodstypeId);

    }



}
